﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CMN.BLL;
using CMN.Common;
using CMN.Entity;
using CMN.Models.Interfaces;
namespace CMN.Models
{
    /// <summary>
    /// 系统应用字段Service
    /// </summary>
    public class Sys_FieldService : IDataService<Sys_FieldEntity>
    {
        /// <summary>
        /// 新增系统应用字段
        /// </summary>
        /// <param name="Sys_FieldEntity"></param>
        /// <returns>bool</returns>
        public string Insert(Sys_FieldEntity sys_fieldEntity)
        {
            sys_fieldEntity.DataTable_Action = DataTableAction.Insert;
            BLLHelper bll = new BLLHelper();
            if (bll.Sys_FieldInsertUpdateDelete(sys_fieldEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 返回系统应用字段查询列表
        /// </summary>
        /// <param name="qp"></param>
        /// <param name="count">查询总个数</param>
        /// <returns>List</returns>
        public List<Sys_FieldEntity> List(QueryParam qp, out int count)
        {
            BLLHelper bll = new BLLHelper();
            return bll.Sys_FieldList(qp, out count);
        }

        /// <summary>
        /// 更新系统应用字段
        /// </summary>
        /// <param name="Sys_Field"></param>
        /// <returns>bool</returns>
        public string Update(Sys_FieldEntity sys_fieldEntity)
        {
            sys_fieldEntity.DataTable_Action = DataTableAction.Update;
            BLLHelper bll = new BLLHelper();
            if (bll.Sys_FieldInsertUpdateDelete(sys_fieldEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 删除系统应用字段
        /// </summary>
        /// <param name="Sys_Field"></param>
        /// <returns>bool</returns>
        public string Delete(Sys_FieldEntity sys_fieldEntity)
        {
            sys_fieldEntity.DataTable_Action = DataTableAction.Delete;
            BLLHelper bll = new BLLHelper();
            if (bll.Sys_FieldInsertUpdateDelete(sys_fieldEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 批量删系统应用字段
        /// </summary>
        /// <param name="idList">删除id列表  2_8_9_45</param>
        /// <returns>bool</returns>
        public string DeleteList(string idList)
        {
            string[] list = Utils.SplitString(idList, "_");
            string strDel = Utils.ArrayToString(list, ",", false);
            BLLHelper bll = new BLLHelper();
            if (bll.Sys_FieldDelList(strDel) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }

        }

        /// <summary>
        /// 返回单个系统应用字段
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Sys_FieldEntity</returns>
        public Sys_FieldEntity Look(int id)
        {
            BLLHelper bll = new BLLHelper();
            return bll.Sys_FieldDisp(id);
        }
    }
}
